package com.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

/**
 * Created by TimeLiar on 2015/9/22.
 *
 */
public class MySet<T> implements Set<T> {
    private ArrayList<T> setArray = new ArrayList<>();
    @Override
    public int size() {
        return setArray.size();
    }

    @Override
    public boolean isEmpty() {
        return setArray.isEmpty();
    }

    @Override
    public boolean contains(Object o) {
        return setArray.contains(o);
    }

    @Override
    public Iterator<T> iterator() {
        return setArray.iterator();
    }

    @Override
    public Object[] toArray() {
        return setArray.toArray();
    }

    @Override
    public <T1> T1[] toArray(T1[] a) {
        return setArray.toArray(a);
    }

    @Override
    public boolean add(T t) {
        return !contains(t) && setArray.add(t);
    }

    @Override
    public boolean remove(Object o) {
        return setArray.remove(o);
    }

    @Override
    public boolean containsAll(Collection<?> c) {
        return setArray.containsAll(c);
    }

    @Override
    public boolean addAll(Collection<? extends T> c) {
        return setArray.addAll(c);
    }

    @Override
    public boolean retainAll(Collection<?> c) {
        return setArray.retainAll(c);
    }

    @Override
    public boolean removeAll(Collection<?> c) {
        return setArray.removeAll(c);
    }

    @Override
    public void clear() {
        setArray.clear();
    }

    @Override
    public String toString(){
        return setArray.toString();
    }

}
